#ifndef _CENTITY_H_
    #define _CENTITY_H_

#include <list>
#include <vector>

#include "CArea.h"
#include "CAnimation.h"
#include "CCamera.h"
#include "CFPS.h"
#include "CSurface.h"

enum EntityType
{
    ENTITY_TYPE_GENERIC,
    ENTITY_TYPE_PLAYER,
    ENTITY_TYPE_ENEMY
};
 
enum EntityFlag
{
    ENTITY_FLAG_NONE     = 0,
    ENTITY_FLAG_GRAVITY  = 0x00000001,
    ENTITY_FLAG_GHOST    = 0x00000002,
    ENTITY_FLAG_MAPONLY  = 0x00000004
};
 
class CEntity
{
    private:
        bool PosValid(int NewX, int NewY);
        bool PosValidTile(CTile* Tile);
        bool PosValidEntity(CEntity* Entity, int NewX, int NewY);
    
    protected:
        CAnimation Anim_Control;
        SDL_Surface* Surf_Entity;
        int CurrentFrameCol;
        int CurrentFrameRow;
        int Col_X;
        int Col_Y;
        int Col_Width;
        int Col_Height;
        float SpeedX;
        float SpeedY;
        float AccelX;
        float AccelY;
        bool CanJump;
    
    public:
        CEntity();
        virtual ~CEntity();
        
        static std::list<CEntity*> EntityList;

        virtual bool OnLoad(char* File, int Width, int Height, int MaxFrames);
        virtual void OnLoop();
        virtual void OnRender(SDL_Surface* Surf_Display);
        virtual void OnCleanup();
        virtual void OnAnimate();
        virtual bool OnCollision(CEntity* Entity);
        void OnMove(float MoveX, float MoveY);
        void StopMove();
        bool Collides(int oX, int oY, int oW, int oH);
        bool Jump();
        void StartDeath();
        void EndDeath();
        
        float X;
        float Y;
        int Width;
        int Height;
        bool MoveLeft;
        bool MoveRight;
        EntityType Type;
        bool Dead;
        bool Dying;
        int DeathFrames;
        int Flags;
        float MaxSpeedX;
        float MaxSpeedY;
};
 
class CEntityCol
{
    public:
        CEntityCol();
        static std::vector<CEntityCol> EntityColList;
        CEntity* EntityA;
        CEntity* EntityB;
};
 
#endif.